package com.example.springshelldemo;

import com.exapmle.commands.Cmd1;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.ParameterResolver;

import java.util.List;

@Configuration
public class MyCommandsAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(Cmd1.Command.class)
    @ConditionalOnProperty(prefix = "my.shell.command.cmd1", value = "enabled", havingValue = "true", matchIfMissing = true)
    public Cmd1 cmdTest(List<ParameterResolver> parameterResolvers) {
        return new Cmd1(parameterResolvers);
    }

}